package com.zmn.oms.business.impl.mapping;

import com.zmn.oms.business.interfaces.mapping.MapCityTmallService;
import com.zmn.oms.model.entity.map.MapCityTmall;
import com.zmn.oms.persistence.interfaces.map.MapCityTmallDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 类描述：
 *
 * @author LiangHailong
 * @date 2019/09/17 22:13
 */
@Service
public class MapCityTmallServiceImpl implements MapCityTmallService {
    @Resource
    private MapCityTmallDao mapCityTmallDao;

    @Override
    public MapCityTmall findMapCityTmallByTmStreetIdOrCountyId(Long tmStreetIdOrCountyId) {
        if (tmStreetIdOrCountyId == null) {
            return null;
        }

        int length = String.valueOf(tmStreetIdOrCountyId.longValue()).length();
        if (length == 9) {
            // tmStreetId
            return mapCityTmallDao.findMapCityTmallByTmStreetId(tmStreetIdOrCountyId);
        }
        else if (length == 6) {
            // tmCountyId
            return mapCityTmallDao.findMapCityTmallByTmCountyId(tmStreetIdOrCountyId);
        }
        else {
            return null;
        }
    }
}
